#include <iostream>
#include <stdio.h>

using namespace std;

int a[100][100];
int main() {
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= i; j++){
            cin >> a[i][j];
            if(!((i == 0) && (j == 0))){
                int d = a[i-1][j] + a[i][j];
                int dle = a[i-1][j-1] + a[i][j];
                a[i][j] = max(d,dle);
            }
        }
    }
    int ma = -1;
    for(int i = 0; i < n; i++){
        if(a[n-1][i] > ma){
            ma = a[n-1][i];
        }
    }
    cout << ma;
    return 0;
}